package controller;
import java.io.File;
import view.Designer;
import view.TemplateList;
import io.ImportXML;/** * An event listener class for the list of templates on the designer * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer * */
public class TemplateListEventHandler extends EventHandler
{	/**	 * Creates the appropriate event from a message passed to this method	 * @param the event object with the message needed to identify the behaviour required.	 */
	public void createEvent(CustomEvent event) 
	{
		if (event.getName().equals("importXML"))
		{
			TemplateList tl = ((TemplateList) event.getSource());
			Designer designer = Designer.getInstance();
			File[] files = ((TemplateList) event.getSource()).getFiles();
			for (File file : files)
			{
				if (tl.getFileName(file).equals(tl.getSelected()))
				{
					ImportXML.importXML(file);
					designer.switchLists(false);
				}
			}
		}
	}
}